package io.renren.common.utils;

import com.alibaba.druid.filter.config.ConfigTools;

/**
 * 数据库密码加密工具类
 */
public class DataSourcePasswordUtils {

    /**
     * 加密
     * @param cipherText
     * @return
     * @throws Exception
     */
    public static String encrypt(String cipherText) throws Exception {
        String encrypt = ConfigTools.encrypt(cipherText);
        return encrypt;
    }

    /**
     * 解密
     * @param cipherText
     * @return
     * @throws Exception
     */
    public static String decrypt(String cipherText) throws Exception {
        String decrypt = ConfigTools.decrypt(cipherText);
        return decrypt;
    }

    public static void main(String[] args) throws Exception {
        String password = "LQF1203698836lqf";
        String encrypt = encrypt(password);
        System.out.println(encrypt);
        String decrypt = decrypt(encrypt);
        System.out.println(decrypt);

        String encrypt1 = ConfigTools.encrypt("MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAhcgsCzdiN9UZUr8UIOy4Xjrta8wjRFNvjhIpekBVxMHgXSG1Ivu7/R3HsTT9kRTE2zsv4b/3h+xXtLW64Un95QIDAQABAkEAgkwhyZLZkHN2xIbiPecQ8oYGM5WRS7zPy9mYmD8MyiJ5u9y1VjoLZxezJyjI2eqkKSTtTJNwLS+G161yUEyJCQIhALlVALifTgXGomgjXHQU3REYetgD7Gyfs4X9ptZAYQSvAiEAuMsoOY2B1CTOeyTY4cXfCtlTs2x3XeOYR9kZdQmDM6sCIHNhkUZfn3KHHJsa0LdQOeUnyWrs3mct8dVMem7Ou9fvAiAyw0Qagz/d2fqKo3Wcl7GMlmTCzhIATawgWIgAuYs8HwIhAKcHAQVytzDyBs5M2lDw2Ri9/49rLI0fZ6ORHpqAIQL4",
                "LQF1203698836lqf");
        System.out.println(encrypt1);
        System.out.println(ConfigTools.decrypt("MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIXILAs3YjfVGVK/FCDsuF467WvMI0RTb44SKXpAVcTB4F0htSL7u/0dx7E0/ZEUxNs7L+G/94fsV7S1uuFJ/eUCAwEAAQ==",encrypt1));
    }
}

